package cst.a118lw.startproject_118lw.model;

import WeatherIface;
import cst.a118lw.startproject_118lw.service.WeatherService;

/**
 * Created by liang on 2017/5/7.
 */

public class WeatherModel implements WeatherIface {
    private Retrofit retrofit;
    private WeatherService service;
    public  static  final  String BASE_URL="http://www.weather.com.cn";

    public WeatherModel(){
        retrofit=new Retrofit.Builder();
                             .baseUrl(BASE_URL);
                             .addConverterFactory(GsonConverFactory.create())
                             .build();
    }
    public WeatherInfo WeatherModel(String c, WealtherListener l){
        service=retrofit.create(WeatherService.class);
        Call<WealtherResult> call=service.getWeather(c);
        call.enqueue(new Callback<WeatherResult>(){
            @Override
            public void onResponse(Call<WeatherResult> call,
                                     Resonpse<WeatherResult> response){
                1.onResponse(resonpse.body().getWeatherInfo());
            }
            @Override
            public void onFailure(Call<WeatherResult> call.Throwable t){
                1.onFail(t.toString());
            }
        })


    }

    public void getWeatherModel(String s, WeatherListener listener) {
    }
}
